package and.activity;

import java.util.HashMap;

import and.common.MyCommon;
import and.process.QueryProcess;
import android.R.bool;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;

public class StatisticsListActivity extends MainActivity {

	private String selectName;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setNowActivity(this);
		elv.setOnChildClickListener(new OnChildClickListener(){
			public boolean onChildClick(ExpandableListView parent, View v,
					int groupPosition, int childPosition, long id) {
				HashMap<String,String> map =(HashMap<String,String>)adapter.getChild(groupPosition, childPosition);
				selectName = map.get(MyCommon.CPWANFA);
				boolean flag =true;
				try{
					if(selectName.equals(MyCommon.DFGUANGDONG)){
						new AlertDialog.Builder(getNowActivity().getParent())
						.setTitle("选择玩法")
						.setItems(MyCommon.GDWANFA, new OnClickListener(){
							public void onClick(DialogInterface dialog,
									int which) {
								selectName = MyCommon.GDWANFA[which];
								QueryProcess query = new QueryProcess();
								query.initQuery(selectName);
								try{
									BaseActivityGroup.changeActivity(StatisticsListActivity.this, "StatisticsActivity");	
								}catch (Exception e) {
									e.printStackTrace();
								}
							}
						}).show();
						flag =false;
						
					}
					if(flag){
						QueryProcess query = new QueryProcess();
						query.initQuery(selectName);
						System.out.println("--->"+MyCommon.StatisticsFile);
						BaseActivityGroup.changeActivity(StatisticsListActivity.this, "StatisticsActivity");
					}
					return true;
				}catch (Exception e) {
					System.out.println("切换activity出错");
					e.printStackTrace();
					return false;
				}
			}
		});
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		return true;
	}
	
}
